﻿
namespace ATTools.Helpers
{
    public static class AudioSupportHelper
    {
        public static string GetPlayType(string audioUrl)
        {
            if (audioUrl == null)
                return "";
            //Find out which media type it is, for checking of audio support in browser
            string fileExt = audioUrl.Substring(audioUrl.LastIndexOf('.') + 1);
            string playType = "";
            switch (fileExt)
            {
                case "wav":
                    playType = "audio/wav; codecs=\"1\"";
                    break;
                case "mp3":
                    playType = "audio/mpeg;";
                    break;
                case "ogg":
                    playType = "audio/ogg; codecs=\"vorbis\"";
                    break;
                case "m4a":
                    playType = "audio/x-m4a;";
                    break;
                case "aac":
                    playType = "audio/aac;";
                    break;
                default:
                    break;
            }
            return playType;
        }
    }
}